package com.herui.ota.controller;

import cn.hutool.core.bean.BeanUtil;
import com.herui.ota.config.ControllerNames;
import com.herui.ota.entity.BaseTree;
import com.herui.ota.entity.DeviceXinpianEvent;
import com.herui.ota.entity.OpsRecord;
import com.herui.ota.pojo.form.DeviceXinpianEventFilterForm;
import com.herui.ota.pojo.form.DeviceXinpianEventForm;
import com.herui.ota.pojo.form.OpsRecordFilterForm;
import com.herui.ota.service.DeviceTreeService;
import com.herui.ota.service.DeviceXinpianEventService;
import com.mlnx.common.annotations.NeedLogin;
import com.mlnx.common.entity.Response;
import com.mlnx.common.entity.ResponseData;
import com.mlnx.common.enums.BusinessType;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.poi.ss.formula.functions.T;
import org.shan.spring.base.CurdBaseController;
import org.shan.spring.base.UrdBaseController;
import org.shan.spring.base.annotations.SysLog;
import org.shan.spring.mybatis.service.ICurdService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;
import java.util.List;

@Api(value = ControllerNames.DeviceXinpianEventName + "接口", tags = {ControllerNames.DeviceXinpianEventName + "接口"})
@SysLog(title = ControllerNames.DeviceXinpianEventName)
@RestController
@RequestMapping("/deviceXinpianEvent")
public class DeviceXinpianEventController extends UrdBaseController<DeviceXinpianEvent, DeviceXinpianEvent,
        DeviceXinpianEventFilterForm> {

    @Autowired
    private DeviceXinpianEventService service;

    @Override
    public ICurdService getService() {
        return service;
    }

    @Override
    public DeviceXinpianEvent newInstance(Integer integer) {
        DeviceXinpianEvent deviceXinpianEvent = new DeviceXinpianEvent();
        deviceXinpianEvent.setId(integer);
        return deviceXinpianEvent;
    }

    @NeedLogin
    @SysLog(
            businessType = BusinessType.INSERT
    )
    @ApiOperation(
            value = "新增",
            notes = ""
    )
    @PostMapping({""})
    public Response add(@Valid DeviceXinpianEventForm form) throws IllegalAccessException, InstantiationException {
        service.save(form);
        return this.result();
    }
}
